class SkipList(object):
    
    class Node(object):
        def __init__(self):
            self.__key = None
            self.__value = None
            self.__level = 0
            self.__nexts = []

        @property
        def key(self):
            return self.__key
        @key.setter
        def key(self, val):
            if value != self.__key :
                self.__key = val
        @property
        def value(self):
            return self.__value
        @value.setter
        def value(self, val):
            if val != self.__value :
                self.__value = val

        @property
        def level(self):
            return self.__level
        @level.setter
        def level(self, val):
            if val != self.__level :
                self.__level = val

        @property
        def nexts(self):
            return self.__nexts
        @nexts.setter
        def nexts(self, val):
            if val != self.__nexts :
                self.__nexts = val

    def __init__(self, maxLevel=2):
        self.__head = SkipList.Node()
        self.__tail = SkipList.Node()
        self.__maxLevel = maxLevel > 0 and maxLevel or 1
        for i in range(self.__maxLevel):
            self.__head.nexts.append(self.__tail)

    def clear(self):
        while self.__head.nexts[0] != self.__tail:
            cur = self.__head.nexts[0]
            self.__head.nexts[0] = cur.nexts[0]
            cur = None
        self.__tail = None
        self.__head = None

    def __str__(self):
        return "SkipList"

    def insertOrReplace(self, key, value):
        pass

    def delete(self, key):
        pass

    def find(self, key):
        pass


import unittest
class TestSkipList(unittest.TestCase): 
    def test(self):
        sl = SkipList()
        sl.insertOrReplace(1, 12)
        sl.find(1)
        sl.delete(1)
        print(str(sl))
        sl.clear()

if __name__ == "__main__":
    suite = unittest.TestSuite([
        unittest.TestLoader().loadTestsFromTestCase(TestSkipList),
        ])
    unittest.TextTestRunner(verbosity=2).run(suite)
